<template>
	<view class="all">
		<view class="status_bar">
		            <!-- 这里是状态栏 -->
		        </view>
		<view class="fidexs">
			<view class="all_title">
				<view class="groups" @click="tos">
					<u-icon name="arrow-left" :bold="true" color="rgba(46, 46, 46, .5)" size="20"></u-icon>
					<view class="mod">热销榜</view>
				</view>
				<u-icon name="home" color="rgba(46, 46, 46, .5)" @click="mesg" size="28"></u-icon>
			</view>
			<u-tabs class="mo" lineHeight="0"  activeStyle="color: #ffa600;border-bottom: 2rpx solid #ffa600;padding-bottom:10rpx"  :list="list1" @click="click"></u-tabs>
		</view>
		<view class="top_nav">
			<view class="list_book" v-for="(item,index) in list"  @click="pop(item.sourceId)">
				<image :src="item.coverUrl">
				</image>
				<view class="list_book_right">
					<view class="list_book_title">
						{{item.title}}
					</view>
					<u--text :lines="2" line-height="20px" size="12" color="rgba(46,46,46,.5)" :text="item.intro">
					</u--text>
					<view class="list_book_i">
						<text class="names">{{item.authorName}}</text>
						<view class="cupe_t">
							<text :style="item.subCategoryName==undefinde ? 'display:none':'dispaly:block' " class="names_c">{{item.subCategoryName}}</text>
							<text class="names_c">{{item.categoryName}}</text>
							<text class="names_t">{{item.allWords | words}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-notify message="Hi uView" :show="show"></u-notify>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				list1: [{
					name: '完结推荐',
				}, {
					name: '最新完结',
				}],
				list: [],
				id:0,
				num: 1,
				nums:'',
				show:false
			}
		},
		filters:{
			words(value){
				return Math.floor(value / 10000) + "万字"  
			}
			
		},
		methods: {
			tos() {
				uni.navigateTo({
					url: "/pages/message/message"
				})
			},
			mesg() {
				uni.navigateBack({
					url: '/pages/message/message'
				})
			},
			click(item) {
				var id=item.index
				this.id=item.index
				this.get(id)
			},
			get(id=0){
				uni.$http.get('https://m.taoyuewenhua.com/ajax/book_mall/end_books?ctype='+this.nums+'&page=0&pageSize=10&ebtype='+id
					).then(res => {
					this.list = res.data.data.bookList
					console.log(this.list)
				}).catch(err => {
				console.log(err)
				})
			},
			pop(id){
				console.log(id,999454546)
				uni.navigateTo({
					url:'/pages/books/books?sourceId='+id
				})
			},
		},
		onLoad(Option){
			console.log(Option,'完结')
			this.nums=Option.nums
			this.get()
		},
		onReachBottom() {
			uni.$http.get('https://m.taoyuewenhua.com/ajax/book_mall/end_books?ctype='+this.nums+'&page='+this.num+'&pageSize=10&ebtype='+this.id
				).then(res => {
				if (res.statusCode == 400) {
					this.show = true;
					return;
				}
				console.log(res,"加载")
				this.num++
				this.list = [...this.list, ...res.data.data.bookList]
			}).catch(err => {
			console.log(err)
			})
		},
	}
</script>

<style lang="scss">
	 .status_bar {
	        height: var(--status-bar-height);
	        width: 100%;
	    }
	.fidexs {
		    position: fixed;
		   top: var(--status-bar-height);
		    right: 0;
		    left: 0;
		    background: #fff;
		    z-index: 11;
			border-bottom: 2rpx solid #eee;
	}
	.all_title {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
		height: 80rpx;
		border-bottom: 2rpx solid #ededed;
		background-color: #fff;
	
		.groups {
			display: flex;
			align-items: flex-end;
	
			.mod {
				margin-left: 20rpx;
			}
		}
	}
	.top_nav {
		padding: 180rpx 30rpx 0;
		.list_book {
			display: flex;
			padding: 0rpx 0rpx 30rpx;
			border-bottom: 2rpx solid #ededed;
			margin-top: 30rpx;
			image {
				width: 150rpx;
				height: 200rpx;
				padding-right: 20rpx;
			}
	
			.list_book_right {
				width: 75%;
				display: flex;
				flex-direction: column;
	
				.list_book_title {
					color: 2e2e2e;
					font-size: 26rpx;
					font-weight: bolder;
					margin-bottom: 22rpx;
				}
	
				.list_book_i {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 22rpx;
	
					.names {
						font-size: 24rpx;
						color: rgba(46, 46, 46, .5);
					}
	
					.cupe_t {
						display: flex;
	
						.names_t {
							text-align: center;
							margin-right: 10rpx;
							padding: 0 12rpx;
							background-color: #f6f6f6;
							font-size: 24rpx;
							color: rgba(46, 46, 46, .5);
						}
						.names_c {
							text-align: center;
							margin-right: 10rpx;
							padding: 0 12rpx;
							background-color: #f6f6f6;
							font-size: 24rpx;
							color: rgba(46, 46, 46, .5);
						}
					}
				}
			}
		}
	
	}
	.mo ::v-deep .u-tabs__wrapper__nav {
		    display: flex;
		    flex-direction: row;
		    flex: 1;
		    position: relative;
		    justify-content: space-around;
	}
</style>
